"""
广场模型

用户可以在广场发送动态
用户发送广场动态后，由审核员进行审核
"""


from django.db import models
from account.models import Account
from django.utils import timezone

# Create your models here.
STATUS_DICT = [
    (0, '未审核'),
    (1, '审核中'),
    (2, '审核通过'),
    (3, '未通过'),
]


class SquareDynamic(models.Model):
    """
    广场模型
    """
    user = models.ForeignKey(Account, on_delete=models.CASCADE, verbose_name='广场动态发布人')
    create_time = models.DateTimeField(default=timezone.now, verbose_name='动态发布时间')
    content = models.TextField(default='', verbose_name='动态内容')
    status = models.IntegerField(default=0, choices=STATUS_DICT, verbose_name='状态')

    class Meta:
        """
        重命名
        """
        db_table = 'square_dynamic'


class SquareComment(models.Model):
    """
    广场动态的评论
    """
    user = models.ForeignKey(Account, on_delete=models.CASCADE, verbose_name='广场动态评论人')
    square_dynamic = models.ForeignKey(SquareDynamic, on_delete=models.CASCADE)
    create_time = models.DateTimeField(default=timezone.now, verbose_name='动态发布时间')
    content = models.TextField(default='', verbose_name='动态内容')
    parent_id = models.IntegerField(default=0, verbose_name='父评论id')

    class Meta:
        """
        重命名
        """
        db_table = 'square_comment'
